package Homework0816;

import java.io.*;
import java.nio.file.Files;

public class Test03 {
    public static void main(String[] args) {
        File dir = new File(".");
        File[] files=dir.listFiles();
        for(File f : files)
        {
            System.out.println(f.getName());
            if(f.isFile()&&f.getName().endsWith(".obj"))
            {
                System.out.println(f.getName());
                try(FileInputStream fis= new FileInputStream(f);
                    ObjectInputStream ois=new ObjectInputStream(fis);)
                {
                    Object obj=ois.readObject();
                    if(obj instanceof User)
                    {
                        System.out.println(obj);
                    }
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        }

//        try (FileInputStream fis= new FileInputStream(file);
//             ObjectInputStream ois=new ObjectInputStream(fis);)
//        {
//            Object obj=ois.readObject();
//            if(obj instanceof User);
//        } catch (IOException e) {
//            throw new RuntimeException(e);
//        } catch (ClassNotFoundException e) {
//            throw new RuntimeException(e);
//        }
    }
}
